<?php 
	require('include/top.php');

	if (!empty($_POST['titre']) && !empty($_POST['content'])){
		
		$link = mysql_connect(DB_HOST, DB_USER, DB_PWD);
		
		//Recuperation de la date
		/*$date= date('d m Y');
		echo $date;*/
		
		$nvArticle= new Article();
		$nvArticle->art_title= $_POST['titre']; 
		$nvArticle->art_content= $_POST['content']; 
		$nvArticle->art_category_id= $_POST['idCategorie'];
		$nvArticle->art_url_photo= $_POST['urlImg'];
		$nvArticle->art_date= $date; 
		
		$nvArticle->insert(); 
		
		mysql_close($link);
		
		header("Location: index.php");

	}

	else{

		$listeCategories= Category::getAll();
		//echo $listeCategories[0];
		
		include('templates/header.tpl.php');
		include('templates/formulaireArticle.tpl.php');
		include('templates/footer.tpl.php');
	}
 ?> 